package com.example.demo.common;

import lombok.Data;

/**
 * Created with IntelliJ IDEA.
 * Description
 * User: 杰
 * Date: 2023 -08 -12
 * Time: 21:29
 */
// 用来返回统一格式
@Data
public class ResultAjax {
    private int code;
    private String msg;
    private Object data;

    public static ResultAjax succ(Object data) {
        ResultAjax result = new ResultAjax();
        result.setCode(200);
        result.setMsg("");
        result.setData(data);
        return result;
    }

    public static ResultAjax succ(Object data, String msg, int code) {
        ResultAjax result = new ResultAjax();
        result.setCode(code);
        result.setMsg(msg);
        result.setData(data);
        return result;
    }

    public static ResultAjax fail(int code, String msg) {
        ResultAjax result = new ResultAjax();
        result.setData(null);
        result.setCode(code);
        result.setMsg(msg);
        return result;
    }

    public static ResultAjax fail(int code, String msg, Object data) {
        ResultAjax result = new ResultAjax();
        result.setData(data);
        result.setCode(code);
        result.setMsg(msg);
        return result;
    }
}
